<template>
	<view>

		<view class="flex padding bg-white">
			<image :src="dataCentre.img" style="width:200rpx;height:200rpx;border-radius: 10rpx;"></image>
			<view class="flex flex-direction justify-between margin-left">
				<view class="text-black text-bold text-lg">{{dataCentre.serviceName}}</view>
				<view class="flex">
					<view v-if="dataCentre.tags1.length>0" class="btn margin-right-xs"
						v-for="(item,index) in dataCentre.tags1" :key='index'>{{item}}</view>
				</view>
				<!-- <view v-if="type==1">库存：{{dataCentre.inventory?dataCentre.inventory:0}}</view> -->
				<view class="text-lg text-red"><text class="text-sm">¥</text>{{dataCentre.money}}</view>
			</view>
		</view>

		<view class="padding bg-white">
			<text class="text-bold text-black text-lg ">服务介绍</text>
			<u-parse class='margin-top' :html="dataCentre.serviceDescribe"></u-parse>
		</view>

		<view class="padding margin-top-sm bg-white">
			<view class="text-bold text-black text-lg ">其他信息</view>
			<view class="flex justify-between align-center margin-tb-sm">
				<view style="font-size:30upx;color:#999999;">服务价格</view>
				<view class="text-black">{{dataCentre.money?dataCentre.money:'暂无'}}</view>
			</view>
			<view class="flex justify-between align-center margin-tb-sm">
				<view style="font-size:30upx;color:#999999;">标签</view>
				<view class="text-black">{{dataCentre.tags?dataCentre.tags:'暂无'}}</view>
			</view>
		</view>

		<view class="padding margin-top-sm bg-white" v-if="type==1">
			<view class="text-bold text-black text-lg ">其他设置</view>
			<view class="flex justify-between align-center margin-tb-sm">
				<view>商品状态</view>
				<u-switch @change="change" active-color="#FFCC00" v-model="dataCentre.isEnable"></u-switch>
			</view>
		</view>
		<view class="addgood" @click="goAdd(dataCentre.goodsId)">修改商品</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
					name: '标准'
				}],
				count: 0,
				lists: [{
					name: '无糖'
				}, {
					name: '少糖'
				}, {
					name: '半糖'
				}],
				counts: 0,
				goodsId: '',
				good: {},
				dataCentre: {
					tags1: []
				},
				checked: false,
				shopId: '',
				inventory: '',
				type: 1,
				status: 1,
				attrList: [],
				skuList: [],
			}
		},
		onLoad(option) {
			// uni.showLoading({
			// 	title: '加载中......',
			// 	icon: 'loading'
			// })
			if (option.data) {
				this.dataCentre = JSON.parse(decodeURIComponent(option.data))
				this.dataCentre.tags1 = this.dataCentre.tags.split(',')
			}
			console.log(JSON.parse(decodeURIComponent(option.data)), "option")
			// this.goodsId = option.goodsId
			this.shopId = uni.getStorageSync('shopId')
			// this.type = option.type
			// this.getGoodDet()
		},
		onShow() {

		},
		methods: {
			goAdd(goodsId) {
				uni.navigateTo({
					url: '/my/publish/goods?goodsId=' + goodsId
				})
			},
			change(e) {
				console.log(e);
				
				let that = this
				if(e == true){
					this.dataCentre.isEnable = 1
				}else if(e == false){
					this.dataCentre.isEnable = 0
				}
				let data = {
					serviceId: this.dataCentre.serviceId,
					modularId: this.dataCentre.modularId,
					isEnable: this.dataCentre.isEnable,
				}
				that.$Request.postA("/admin/hospitalEmploy/updateHospitalEmploy", data).then(res => {
					if (res.code == 0) {
						// that.getGoodsList()
						uni.showToast({
							title: e ? '上架成功' : '下架成功',
							icon: 'none'
						})
					}
				});
			},
			getGoodDet() {
				if (this.type == 1) {
					let data = {
						goodsId: this.goodsId,
						shopId: this.shopId
					}
					this.$Request.getA("/admin/goodsShop/selectGoodsByShopIdAndGoodsId", data).then(res => {
						if (res.code == 0) {
							uni.hideLoading()
							this.dataCentre = res.data

							this.attrList.forEach(res => {
								let data = {
									name: ''
								}
								// this.checkStateList.push(data);
								let detail = [];
								res.detail.split(',').forEach(d => {
									let data = {
										name: '',
										state: ''
									}
									data.name = d;
									detail.push(data);
								});
								res.detail = detail;
							})
							console.log(this.attrList)
						}
					});
				} else {
					let data = {
						goodsId: this.goodsId
					}
					this.$Request.getA("/admin/goods/selectGoodsById", data).then(res => {
						if (res.code == 0) {
							uni.hideLoading()
							this.dataCentre = res.data
							this.attrList.forEach(res => {
								let data = {
									name: ''
								}
								// this.checkStateList.push(data);
								let detail = [];
								res.detail.split(',').forEach(d => {
									let data = {
										name: '',
										state: ''
									}
									data.name = d;
									detail.push(data);
								});
								res.detail = detail;
							})
							console.log(this.attrList)
						}
					});
				}

			},



		}
	}
</script>

<style>
	page {
		background: #EDF1F7;
	}

	.bg {
		background: #FFFFFF;
	}

	.btn {
		background: rgba(216, 2, 4, 0.2);
		opacity: 0.6;
		border-radius: 4upx;
		color: #D80204;
		padding: 8rpx 13rpx;
		font-size: 23rpx;
		margin-right: 16rpx;
	}

	.box {
		border: 2upx solid #CCCCCC;
		/* opacity: 0.6; */
		border-radius: 8upx;
		color: #999999;
		font-size: 30upx;
		padding: 13rpx 44rpx;
		margin-right: 35rpx;
	}

	.boxs {
		background: rgba(252, 210, 2, 0.2);
		border: 2upx solid #FCD202;
		/* opacity: 0.6; */
		border-radius: 8upx;
		color: #333333 !important;
		font-size: 30upx;
		padding: 13rpx 44rpx;
	}

	.addgood {
		width: 685upx;
		height: 88upx;
		background: #FFCC00;
		border-radius: 8upx;
		text-align: center;
		line-height: 88rpx;
		margin: 40rpx auto;
		/* position: fixed;
		bottom: 35rpx;
		left: 0;
		right: 0; */
		font-size: 32rpx;
		font-weight: bold;
		color: #FFFFFF;
	}

	.detail-banner {
		width: 100%;
		height: 410rpx;
	}

	.detail-banner image {
		width: 100%;
		height: 410rpx;
	}

	.detail {
		width: 100%;
		padding: 3%;
		overflow: hidden;
		/* position: relative; */
		/* top: -20rpx; */
		background-color: #FFFFFF;
		border-radius: 32rpx 0 0 0;
	}

	.detail_text {
		font-size: 36rpx;
		font-weight: 800;
		color: #333333;
	}

	.detail_biao {
		display: flex;
		padding: 2% 0;
	}

	.detail_biao_sty {
		/* padding: 1% 1.5%; */
		padding: 10rpx 20rpx;
		background: rgba(216, 2, 4, 0.2);
		opacity: 0.6;
		color: #D80204;
		border-radius: 8rpx;
		font-size: 24rpx;
		margin-right: 2%;
	}

	.detail_text2 {
		font-size: 24rpx;
		font-family: PingFang SC;
		color: #333333;
		margin-top: 1%;
	}

	.detail_biao2 {
		display: flex;
		padding: 1% 0;
		font-size: 30rpx;
	}

	.detail_biao2_sty {
		padding: 1% 2.5%;
		/* width: 13%; */
		text-align: center;
		background: rgba(252, 210, 2, 0.2);
		border: 2rpx solid #FCD202;
		opacity: 0.6;
		border-radius: 8rpx;
		margin-right: 2%;
	}

	.detail_biao2_sty2 {
		padding: 1% 2.5%;
		/* width: 13%; */
		text-align: center;
		border: 2rpx solid #999999;
		opacity: 0.6;
		color: #999999;
		border-radius: 8rpx;
		margin-right: 3%;
	}
</style>